/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package systole.processor.filters;

/**
 *
 * @author user
 */
public class FilterSettings implements Cloneable{

    private final double defaultCutoff = 17;
    private final int defaultN = 102;
    private final double defaultAtten = 0.0001f;
    private final double defaultRipple = 0.057501127785f;
    private final double defaultTrband = 0.02f;
    private int defaultIterations = 2;

    private Filter filt;
    private FilterConfiguration fConfig;
    private FilterAlgorithm fAlg;


    /**
     * 
     */
    public FilterSettings(){
    	super();    	
    }

    /**
     * @param filt
     * @param fConfig
     * @param fAlg
     */
    public FilterSettings(Filter filt, FilterConfiguration fConfig, FilterAlgorithm fAlg){
        this.filt = filt;
        this.fConfig = fConfig;
        this.fAlg = fAlg;
    }

    /**
     * @param ps
     */
    public void createDefault(double ps){
        //Ps = 5.9 milisegundos en notebook y FC = 17Hz
        this.filt = new LowPass(ps, this.defaultCutoff);
        this.fConfig = this.filt.config(this.defaultN, this.defaultAtten, this.defaultRipple, this.defaultTrband);
        this.fAlg = new RemezEquiripple();
    }

    /**
     * @return the filt
     */
    public Filter getFilt() {
        return this.filt;
    }

    /**
     * @param filt the filt to set
     */
    public void setFilt(Filter filt) {
        this.filt = filt;
    }

    /**
     * @return the fConfig
     */
    public FilterConfiguration getFConfig() {
        return this.fConfig;
    }

    /**
     * @param fConfig the fConfig to set
     */
    public void setFConfig(FilterConfiguration fConfig) {
        this.fConfig = fConfig;
    }

    /**
     * @return the fAlg
     */
    public FilterAlgorithm getFAlg() {
        return this.fAlg;
    }

    /**
     * @param fAlg the fAlg to set
     */
    public void setFAlg(FilterAlgorithm fAlg) {
        this.fAlg = fAlg;
    }


    @Override
    public Object clone(){

        FilterSettings settingsClone = null;

        try{
            settingsClone = (FilterSettings)super.clone();
            settingsClone.setFilt((Filter)this.filt.clone());
            settingsClone.setFConfig((FilterConfiguration)this.fConfig.clone());
            settingsClone.setFAlg(new RemezEquiripple());
        }catch(CloneNotSupportedException ex){
            ex.printStackTrace();
        }

        return settingsClone;
    }

    /**
     * @return the defaultIterations
     */
    public int getDefaultIterations() {
        return this.defaultIterations;
    }

    /**
     * @param defaultIterations the defaultIterations to set
     */
    public void setDefaultIterations(int defaultIterations) {
        this.defaultIterations = defaultIterations;
    }
    

}
